// index.js
// 获取应用实例
const app = getApp()
const http = require('../../http/http')

Page({ 
  data: {
    dailyrecommodsong: [],
    recommodList: [],
    song: {},
    authorname: "",
    primaryFlag: 0,

    songPic: "",
    songName: "",
    songAuthor: "",
    showPlayer:true,
    showSongRigon:true,
  },
  // 事件处理函数
  bindViewTap() {

  },

  //刷新歌曲和播放区
  onShow() {
    this.setData({
      showPlayer:false,
      showSongRigon:false,
    })
    this.setData({
      showPlayer:true,
      showSongRigon:true,
    })
  },
  
  onHide(){
    this.setData({
      show:false,
    })
  },

  onLoad() {

    const res1 = http.recommodsong({
      limit: 5
    })
    res1.then((data) => {

      console.log(data)
      this.setData({
        dailyrecommodsong: data,
        song: data[0],
        // authorname:data[0].artists[0].name
      })
    })
    const res4 = http.getRecommodList({})
    res4.then((data) => {
      console.log(data.records)
      this.setData({
        recommodList: data.records
      })
      // this.selectComponent("songl-list").refresh();
    })
    
  },

  bindconfirm: function (e) {
    wx.navigateTo({
      url: '/pages/search/search',
    })
  },
  
  //只刷新歌曲区域
  refreshSongRigon(){
      this.setData({
        showSongRigon:false,
      })
      this.setData({
        showSongRigon:true,
    })
  }
})
